package com.cracker.websocket.server.service;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MessageService {
    public String encode(Object data) {
        return JSONObject.toJSONString(data, SerializerFeature.WriteDateUseDateFormat);
    }

    public <T> T decode(String data, Class<T> dtoClass) {
        return JSONObject.parseObject(data, dtoClass);
    }
}
